﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint.Client;
using System.Net;

namespace SharePointClientTest
{
    public partial class SharePointClientWindow : System.Windows.Forms.Form
    {
        public SharePointClientWindow()
        {
            InitializeComponent();
        }

        private void txtGetFields_Click(object sender, EventArgs e)
        {
            WebRequest.DefaultWebProxy = new WebProxy("127.0.0.1", 8888);

            string siteUrl = "http://haitb-moss2010";

            ClientContext clientContext = new ClientContext(siteUrl);
            clientContext.Credentials = new NetworkCredential("administrator", "kofax");

            Web site = clientContext.Web;
            List taskList = site.Lists.GetByTitle("Shared Documents");

            FieldCollection collField = taskList.Fields;
            Field oneField = collField.GetByInternalNameOrTitle("Title");
            oneField.Description = "MyNewFieldDescription";
            oneField.Update();

            clientContext.Load(collField);
            clientContext.Load(oneField);
            clientContext.ExecuteQuery();

            string fieldInfo = "Field Title: " + oneField.Title + "\n" +
               "Description: " + oneField.Description + "\n";
            Console.WriteLine(fieldInfo);
        }
    }
}
